import request from "@/api";
import { BaseRet, PageQuery, PageRet } from "../../response";

class OnlineUserApi {
  /**
   * 查询
   * @returns
   */
  static async query(query: PageQuery): Promise<PageRet<OnlineUser>> {
    return await request({
      url: "/Online/GetOnlineUserList",
      method: "get",
      data: query,
    });
  }

  /**
   * 强制退出登录
   * @returns
   */
  static async logout(tokenId: string): Promise<BaseRet> {
    return await request({
      url: `/Online/Logout/${tokenId}`,
      method: "delete",
    });
  }
}

export default OnlineUserApi;

export interface OnlineUser {
  tokenId?: string;
  userId?: string;
  userName?: string;
  nickName?: string;
  connectionId?: string;
  requestIp?: string;
  ipAddress?: string;
  operatingSystem?: string;
  deviceType?: string;
  browserName?: string;
  version?: string;
  loginTime?: string;
  accessExpiresTime?: string;
  refreshExpiresTime?: string;
}

export interface OnlineUserQuery extends PageQuery {
  searchString?: string;
}
